package com.hz.framework.util;

import java.io.IOException;
import java.io.InputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

import com.hz.framework.dao.DBQ;


public class PropertiesUtil {
   public String getMaxId(String TableName,String id,String PropertiesName){
	   
	   String value="0";
	   String sql ="select MAX(CONVERT(SUBSTR("+id+","+(PropertiesName.length()+1)+",LENGTH("+id+")) ,SIGNED)) "+id+" from "+TableName+" where "+id+" like '%"+PropertiesName+"%'";
	   System.out.println(sql);
	   ResultSet rs=null;
	   DBQ db =new DBQ();
	   try {
			rs =db.query(sql);
			if(rs.next()){
				value=rs.getString(1);
			}
		
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			db.close();
		}
		//System.out.println("value---"+value);
        return Integer.parseInt(value==null?"0":value)+1+"";
   }
   public String getProperties(String PropertiesName){
	   String value="";
	   Properties pts=new Properties();
	   InputStream in = PropertiesUtil.class.getResourceAsStream("/service.properties");
	   try {
			pts.load(in);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	   value=pts.getProperty(PropertiesName);
	   return value;
   }
   public static void main(String[] args) {
	   PropertiesUtil p=new PropertiesUtil();
   }
}
